import request from '@/utils/request'
// 注册功能
export const userRegisterService = ({ email, password, VerificationCode }) =>{
    const data = new FormData();
    data.append('email', email);
    data.append('password', password);
    data.append('verificationCode', VerificationCode);
   return request.post('/register', data)
}

// 登录功能
export const userLoginService = (email, password) => {
    const data=new FormData()
    data.append('email', email);
    data.append('password', password);
    return request.post('/login', data);
}

// 获取邮箱验证码
export const emailVerification= (email) =>{
    return request.get('/mail/emailVerification', { params: { email: email } })
}

// 获取用户基本信息
export const userGetInfoService = (id) =>{
    return request.get(`/userinfo`,{ params: { id: id } })
}

//更新用户个人信息
export const userUpdateInfoService = ({ name,age, phon ,sex, email, id, sign }) =>
    request.put('/updateUser', { name,age, phon ,sex, email, id, sign })

// 更新用户密码
export const userUpdatePassService = (id, old_pwd, new_pwd ) =>{
    alert(id)
 return  request.patch('/updatepwd', {
     id: id,
     old_pwd: old_pwd,
     new_pwd: new_pwd
 })
}

//用户更新头像
export const userUpdateAvatar = (id,avatar) =>{
    return request.get(`/upavatar`,{ params: { id: id ,avatar:avatar} })
}
